package com.company.reptile;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class phantomjs {
    public static void main(String[] args) throws InterruptedException {
        getHtml("http://fundf10.eastmoney.com/jjjz_008279.html");
    }
    public  static   void   getHtml(String url)
    {
        String HTML="";
        String jsPath = "D:\\java_web\\JavaCourse\\src\\com\\company\\reptile\\myjs.js";
        String exePath = "D:\\java_web\\JavaCourse\\src\\com\\company" +
                "\\reptile\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe";
        System.out.println(jsPath);
        System.out.println(exePath);
        Runtime rt = Runtime.getRuntime();
        Process p;
        try {
            p = rt.exec(exePath + " " + jsPath + " " + url);

            InputStream is = p.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            StringBuffer sbf = new StringBuffer();
            String tmp = "";
            while ((tmp = br.readLine()) != null)
            {
                sbf.append(tmp);
            }
            HTML=sbf.toString();

            is.close();
            br.close();
            sbf=null;
            is=null;
            br=null;
        } catch (IOException e) {

            e.printStackTrace();
        }

    }
}
